package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Mapper
public interface OrdersettingMapper {

    /**
     * 根据每月的第一天和每月的最后一天查询范围内的的预约设置信息
     * @param beginOfMonth
     * @param endOfMonth
     * @return
     */
    List<OrderSetting> getOrderSettingByMonth(LocalDate beginOfMonth, LocalDate endOfMonth);

    /**
     * 根据日期修改可预约人数
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);

    /**
     * 根据日期查询
     * @param orderDate
     * @return
     */
    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting findByOrderDate(Date orderDate);

    /**
     * 新增数据
     * @param orderSetting
     */
    @Insert("insert into t_ordersetting (orderDate, number, reservations) VALUES (#{orderDate}, #{number}, #{reservations})")
    void add(OrderSetting orderSetting);
}
